<?php 
namespace Home\Controller;
use Think\Controller;
class ActiveController extends Controller {

    public function getGift() {

        $giftList = [
            [
                "id"   => "1",
                "name" => "沙发",
            ],
            [
                "id" => "2",
                "name" => "iPhone8 PLUS"
            ],
            [
                "id" => "3",
                "name" => "白葡萄酒"
            ],
            [
                "id" => "4",
                "name" => "888元现金红包"
            ]
        ];

        $key = array_rand($giftList);

        $get = $giftList[$key];

        $this->ajaxReturn($get, "JSON");
    }

}